import { createApp } from 'vue';
import App from './App.vue';
import i18n, { locale, loadLanguageAsync } from '@/i18n'; // 确保正确导入

import '@fortawesome/fontawesome-free/css/all.css';

const app = createApp(App);

// 获取用户语言
const initLang = async () => {
    // 从 localStorage 获取用户选择的语言，如果没有则使用 i18n 配置的默认语言
    const savedLocale = localStorage.getItem('user-language');
    const userLang = savedLocale || i18n.global.locale.value;
    await loadLanguageAsync(userLang);
    locale.value = userLang as "zh" | "en" | "ja";
    app.use(i18n);
    app.mount('#app');
}
initLang()